package com.example.content.repository

import com.example.content.repository.bean.*
import com.example.content.repository.bean.charge.*
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * Created by zhudongao
 * Desc
 * Date 2020/10/25
 */
interface ApiService {
    companion object {
        const val BASE_URL = "http://39.98.211.106:8002"
    }

    @POST("/api/v1/sms_code")
    suspend fun sendMsmCode(@Body body:RequestBody):ApiResult<BaseResp>

    @POST("/api/v1/login")
    suspend fun login(@Body body:RequestBody) : ApiResult<UserToken>

    //用户相关
    //获取用户信息
    @POST("/api/v1/users")
    suspend fun getUserInfo(@Body body:RequestBody):ApiResult<List<UserInfo>>

    //修改、更新用户信息
    @POST("/api/v1/users/update")
    suspend fun modifyUserInfo(@Body body:RequestBody):ApiResult<MdUserInfo>

    //获取关注列表
    @POST("/api/v1/users/get_follow")
    suspend fun getFollowers(@Body body: RequestBody): ApiResult<List<UserInfo>>

    //关注/取消关注 action
    @POST("/api/v1/users/follow_user")
    suspend fun follow(@Body body:RequestBody):ApiResult<FollowResp>

    //获取用户的打赏记录
    @POST("/api/v1/users/get_reward")
    suspend fun getUserRewardInfo(@Body body: RequestBody): ApiResult<List<UserRewardResp>>

    //获取用户的收藏
    @POST("/api/v1/users/get_collect")
    suspend fun getUserCollect(@Body body: RequestBody): ApiResult<List<ProductInfo>>

    //上传文件
    @Multipart
    @POST("/api/v1/resource/upload_files")
    suspend fun uploadFile(@Part() parts: List<MultipartBody.Part>): ApiResult<List<String>>

    //上传文件
    @Headers(
        "accept: application/json",
        "Content-Type: multipart/form-data"
    )
    @POST("/api/v1/resource/upload_files")
    suspend fun uploadPhotos(@Body body: MultipartBody): ApiResult<List<String>>

    //
    @GET("/api/v1/resource/{file_name}")
    suspend fun downloadFile(@Path("file_name") file_name: String)

    //
    @POST("/api/v1/creations")
    suspend fun createProduct(@Body body: RequestBody): ApiResult<ProductInfo>

    @POST("/api/v1/creations/info")
    suspend fun getProductInfoById(@Body body: RequestBody):ApiResult<List<ProductInfo>>

    @POST("/api/v1/creations/user")
    suspend fun getUserProducts(@Body body: RequestBody):ApiResult<List<ProductInfo>>

//    @POST("/api/v1/creations/delete")
//    suspend fun delProduct(@Body body: RequestBody):ApiResult<BaseResp>

    @POST("/api/v1/creations/delete")
    suspend fun delProduct(@Query("creation_id") creation_id: Int):ApiResult<String>

    @POST("/api/v1/creations/creation_action")
    suspend fun  userAction(@Body body: RequestBody):ApiResult<String>

    @POST("/api/v1/creations/creation_view/{creationId}")
    suspend fun viewProductById(@Path("creationId") creationId:Int):ApiResult<String>

    //获取作品的查看、收藏、点赞的用户
    @POST("/api/v1/creations/record")
    suspend fun getProductActionUser(@Body body: RequestBody): ApiResult<List<UserInfo>>

    @POST("/api/v1/creations/reward")
    suspend fun rewardProduct(@Body body: RequestBody): ApiResult<BaseResp>

    //获得作品的打赏记录
    @POST("/api/v1/creations/get_reward")
    suspend fun getRewardRecordInfo(@Body body: RequestBody): ApiResult<List<RewardRecord>>

    @POST("/api/v1/feedback")
    suspend fun feedback(@Body body: RequestBody): ApiResult<String>

    //    搜索相关
    @POST("/api/v1/search/query")
    suspend fun searchProduct(@Body body: RequestBody): ApiResult<List<ProductInfo>>

    //    搜索相关
    @POST("/api/v1/search/query")
    suspend fun searchUser(@Body body: RequestBody): ApiResult<List<UserInfo>>

    @GET("/api/v1/search/query_label")
    suspend fun getSearchKey(@Query("key") key: String): ApiResult<List<String>>

    @POST("/admin/api/v1/creations/review_creation")
    suspend fun reviewProduct(@Body body: RequestBody): ApiResult<ReviewProduct>

    @Headers("Cache-Control: public,max-age:604800")
    @POST("/api/v1/recommend")
    suspend fun getRecommend(@Body body: RequestBody): ApiResult<List<ProductInfo>>

    /*************金币接口*******************/

    /**
     * 身份证上传接口
     */
    @Multipart
    @POST("/api/v1/private/upload_id_card")
    suspend fun uploadIdCard(@Part parts: List<MultipartBody.Part>): ApiResult<IdCardUploadResp>

    /**
     * 实名认证接口
     */
    @POST("/api/v1/private/verify_user_name")
    suspend fun userCertification(@Body body: RequestBody): ApiResult<CertificationResp>

    /**
     * 实名认证状态查询
     */
    @POST("/api/v1/private/verify_status")
    suspend fun getUserCertificationStatus(@Body body: RequestBody): ApiResult<CertificationResp>

    /**
     * 添加银行卡
     */
    @POST("/api/v1/private/add_black_card")
    suspend fun addBankCard(@Body body: RequestBody): ApiResult<BankCardInfo>

    /**
     * 删除银行卡信息
     */
    @POST("/api/v1/private/delete_black_card")
    suspend fun deleteBandCard(@Body body: RequestBody): ApiResult<DelBankCardResp>

    /**
     * 获取用户银行卡信息
     */
    @POST("/api/v1/private/get_black_card")
    suspend fun getUserBankCard(@Body body: RequestBody):ApiResult<BankCardInfo>

    /**
     * 获取用户赚金币记录
     */
    @POST("/api/v1/private/user_coin_record")
    suspend fun getUserCoinRecord(@Body body: RequestBody):ApiResult<EarnCoinRecord>
}